import 'dart:convert';

/// 用户信息
class User {
  String id,
      remarks,
      username,
      cellphone,
      email,
      address,
      avatar,
      sex, // 0:女 1：男
      docLevel,
      signature,
      nickname,
      fullname,
      idcard,
      birthDay,
      sectionType,
      skilleds,
      sectionName,
      professionalName,
      office,
      sexValue,
      skilled,
      professionalLevel;

  /// 1 认证成功  2 未认证  3 待认证 4 认证失败
  int authStatus;

  /// 消息免打扰（0：关闭；1：开启）
  int noDisturbing;

  User(
      {this.id,
      this.remarks,
      this.username,
      this.cellphone,
      this.email,
      this.address,
      this.avatar,
      this.sex,
      this.docLevel,
      this.signature,
      this.nickname,
      this.fullname,
      this.idcard,
      this.birthDay,
      this.sectionType,
      this.skilleds,
      this.sectionName,
      this.professionalName,
      this.office,
      this.sexValue,
      this.skilled,
      this.noDisturbing,
      this.professionalLevel,
      this.authStatus});

  factory User.fromJson(Map<String, dynamic> data) {
    return User(
      id: data['id'],
      remarks: data['remarks'],
      username: data['username'],
      cellphone: data['cellphone'],
      email: data['email'],
      address: data['address'],
      avatar: data['avatar'],
      sex: data['sex'],
      docLevel: data['docLevel'],
      signature: data['signature'],
      nickname: data['nickname'],
      fullname: data['fullname'],
      idcard: data['idcard'],
      birthDay: data['birthDay'],
      authStatus: data['authStatus'] == '' ? 2 : data['authStatus'],
      sectionType: data['sectionType'],
      skilleds: data['skilleds'],
      sectionName: data['sectionName'],
      professionalName: data['professionalName'],
      office: data['office'],
      sexValue: data['sexValue'],
      skilled: data['skilled'],
      noDisturbing: data['noDisturbing'] == '' ? 0 : data['noDisturbing'],
      professionalLevel: data['professionalLevel'],
    );
  }

  Map<String, dynamic> toMap() {
    return {
      'id': id,
      'remarks': remarks,
      'username': username,
      'cellphone': cellphone,
      'email': email,
      'address': address,
      'avatar': avatar,
      'sex': sex,
      'docLevel': docLevel,
      'signature': signature,
      'nickname': nickname,
      'fullname': fullname,
      'idcard': idcard,
      'birthDay': birthDay,
      'authStatus': authStatus,
      'sectionType': sectionType,
      'skilleds': skilleds,
      'sectionName': sectionName,
      'professionalName': professionalName,
      'office': office,
      'sexValue': sexValue,
      'skilled': skilled,
      'noDisturbing': noDisturbing,
      'professionalLevel': professionalLevel,
    };
  }

  @override
  String toString() {
    return json.encode(toMap());
  }
}
